package com.cy.jt.controller;

import com.cy.jt.pojo.ItemCatParam;
import com.cy.jt.service.ItemCatParamService;
import com.cy.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description:
 * @author: LiuXingYu
 * @date: 2021/8/6 16:50
 */
@RestController
@RequestMapping("/itemCatParam")
@CrossOrigin
public class ItemCatParamController {

    @Autowired
    private ItemCatParamService itemCatParamService;


//    get("/itemCatParam/findItemCatParamListByType", {params: {itemCatId: itemCatId,paramType: paramType }
    @GetMapping("/findItemCatParamListByType")
    public SysResult findItemCatParamListByType(ItemCatParam itemCatParam){
        List<ItemCatParam> itemCatParamList =
                itemCatParamService.findItemCatParamListByType(itemCatParam);
        return SysResult.success(itemCatParamList);
    }

//    post("/itemCatParam/addItemCatParam", this.addItemCatParam)
    @PostMapping("/addItemCatParam")
    public SysResult addItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.addItemCatParam(itemCatParam);
        return SysResult.success();
    }

//    delete("/itemCatParam/deleteItemCatParamById", {params: {paramId: itemCatParam.paramId}})
    @DeleteMapping("/deleteItemCatParamById")
    public SysResult deleteItemCatParamById(Integer paramId){
        itemCatParamService.deleteItemCatParamById(paramId);
        return SysResult.success();

    }

//    put("/itemCatParam/updateItemCatParam", this.updateItemCatParam)
    @PutMapping("/updateItemCatParam")
    public SysResult updateItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.updateItemCatParam(itemCatParam);
        return SysResult.success();
    }
}

